added some development tools
[windows-sources.git] / developer / Samples / NET 4.6 / Samples for Parallel / Sudoku / Sudoku_CSharp / OptionsDialog.cs
blobe30dc9505313d24f0dda57b7801dd1802287339c
1 //--------------------------------------------------------------------------
2 //
3 // Copyright (c) Microsoft Corporation. All rights reserved.
4 //
5 // File: OptionsDialog.cs
6 //
7 // Description: Dialog for user configuration options.
8 //
9 //--------------------------------------------------------------------------
11 using System;
13 namespace Microsoft.ParallelComputingPlatform.ParallelExtensions.Samples.Sudoku
15 /// <summary>Presents configuration options to the user.</summary>
16 internal class OptionsDialog : System.Windows.Forms.Form
18 private System.Windows.Forms.GroupBox groupBox1;
19 private System.Windows.Forms.CheckBox chkShowIncorrectCells;
20 private System.Windows.Forms.CheckBox chkHighlightEasyCell;
21 private System.Windows.Forms.GroupBox groupBox2;
22 private System.Windows.Forms.GroupBox groupBox3;
23 private System.Windows.Forms.CheckBox chkCreateWithSymmetry;
24 private System.Windows.Forms.CheckBox chkPromptOnDelete;
25 private System.Windows.Forms.Button btnCancel;
26 private System.Windows.Forms.Button btnOK;
27 private System.Windows.Forms.CheckBox chkParallelPuzzleGeneration;
28 private System.Windows.Forms.CheckBox chkSpeculativeGeneration;
29 private System.ComponentModel.Container components = null;
31 /// <summary>Initializes the OptionsDialog.</summary>
32 public OptionsDialog()
34 InitializeComponent();
37 /// <summary>Cleans up.</summary>
38 protected override void Dispose( bool disposing )
40 if( disposing )
42 if(components != null)
44 components.Dispose();
47 base.Dispose( disposing );
50 #region Windows Form Designer generated code
51 /// <summary>
52 /// Required method for Designer support - do not modify
53 /// the contents of this method with the code editor.
54 /// </summary>
55 private void InitializeComponent()
57 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(OptionsDialog));
58 this.groupBox1 = new System.Windows.Forms.GroupBox();
59 this.chkHighlightEasyCell = new System.Windows.Forms.CheckBox();
60 this.chkShowIncorrectCells = new System.Windows.Forms.CheckBox();
61 this.groupBox2 = new System.Windows.Forms.GroupBox();
62 this.chkParallelPuzzleGeneration = new System.Windows.Forms.CheckBox();
63 this.chkCreateWithSymmetry = new System.Windows.Forms.CheckBox();
64 this.groupBox3 = new System.Windows.Forms.GroupBox();
65 this.chkPromptOnDelete = new System.Windows.Forms.CheckBox();
66 this.btnCancel = new System.Windows.Forms.Button();
67 this.btnOK = new System.Windows.Forms.Button();
68 this.chkSpeculativeGeneration = new System.Windows.Forms.CheckBox();
69 this.groupBox1.SuspendLayout();
70 this.groupBox2.SuspendLayout();
71 this.groupBox3.SuspendLayout();
72 this.SuspendLayout();
73 //
74 // groupBox1
75 //
76 resources.ApplyResources(this.groupBox1, "groupBox1");
77 this.groupBox1.Controls.Add(this.chkHighlightEasyCell);
78 this.groupBox1.Controls.Add(this.chkShowIncorrectCells);
79 this.groupBox1.FlatStyle = System.Windows.Forms.FlatStyle.System;
80 this.groupBox1.Name = "groupBox1";
81 this.groupBox1.TabStop = false;
82 //
83 // chkHighlightEasyCell
84 //
85 this.chkHighlightEasyCell.AccessibleRole = System.Windows.Forms.AccessibleRole.HotkeyField;
86 resources.ApplyResources(this.chkHighlightEasyCell, "chkHighlightEasyCell");
87 this.chkHighlightEasyCell.Name = "chkHighlightEasyCell";
88 //
89 // chkShowIncorrectCells
90 //
91 resources.ApplyResources(this.chkShowIncorrectCells, "chkShowIncorrectCells");
92 this.chkShowIncorrectCells.AccessibleRole = System.Windows.Forms.AccessibleRole.HotkeyField;
93 this.chkShowIncorrectCells.Name = "chkShowIncorrectCells";
94 this.chkShowIncorrectCells.CheckedChanged += new System.EventHandler(this.chkShowIncorrectCells_CheckedChanged);
95 //
96 // groupBox2
97 //
98 resources.ApplyResources(this.groupBox2, "groupBox2");
99 this.groupBox2.Controls.Add(this.chkSpeculativeGeneration);
100 this.groupBox2.Controls.Add(this.chkParallelPuzzleGeneration);
101 this.groupBox2.Controls.Add(this.chkCreateWithSymmetry);
102 this.groupBox2.FlatStyle = System.Windows.Forms.FlatStyle.System;
103 this.groupBox2.Name = "groupBox2";
104 this.groupBox2.TabStop = false;
106 // chkParallelPuzzleGeneration
108 this.chkParallelPuzzleGeneration.AccessibleRole = System.Windows.Forms.AccessibleRole.HotkeyField;
109 resources.ApplyResources(this.chkParallelPuzzleGeneration, "chkParallelPuzzleGeneration");
110 this.chkParallelPuzzleGeneration.Name = "chkParallelPuzzleGeneration";
112 // chkCreateWithSymmetry
114 this.chkCreateWithSymmetry.AccessibleRole = System.Windows.Forms.AccessibleRole.HotkeyField;
115 resources.ApplyResources(this.chkCreateWithSymmetry, "chkCreateWithSymmetry");
116 this.chkCreateWithSymmetry.Name = "chkCreateWithSymmetry";
118 // groupBox3
120 resources.ApplyResources(this.groupBox3, "groupBox3");
121 this.groupBox3.Controls.Add(this.chkPromptOnDelete);
122 this.groupBox3.FlatStyle = System.Windows.Forms.FlatStyle.System;
123 this.groupBox3.Name = "groupBox3";
124 this.groupBox3.TabStop = false;
126 // chkPromptOnDelete
128 this.chkPromptOnDelete.AccessibleRole = System.Windows.Forms.AccessibleRole.HotkeyField;
129 resources.ApplyResources(this.chkPromptOnDelete, "chkPromptOnDelete");
130 this.chkPromptOnDelete.Name = "chkPromptOnDelete";
132 // btnCancel
134 resources.ApplyResources(this.btnCancel, "btnCancel");
135 this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
136 this.btnCancel.Name = "btnCancel";
138 // btnOK
140 resources.ApplyResources(this.btnOK, "btnOK");
141 this.btnOK.DialogResult = System.Windows.Forms.DialogResult.OK;
142 this.btnOK.Name = "btnOK";
143 this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
145 // chkSpeculativeGeneration
147 this.chkSpeculativeGeneration.AccessibleRole = System.Windows.Forms.AccessibleRole.HotkeyField;
148 resources.ApplyResources(this.chkSpeculativeGeneration, "chkSpeculativeGeneration");
149 this.chkSpeculativeGeneration.Name = "chkSpeculativeGeneration";
151 // OptionsDialog
153 this.AcceptButton = this.btnOK;
154 resources.ApplyResources(this, "$this");
155 this.CancelButton = this.btnCancel;
156 this.Controls.Add(this.btnOK);
157 this.Controls.Add(this.btnCancel);
158 this.Controls.Add(this.groupBox3);
159 this.Controls.Add(this.groupBox2);
160 this.Controls.Add(this.groupBox1);
161 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
162 this.MaximizeBox = false;
163 this.MinimizeBox = false;
164 this.Name = "OptionsDialog";
165 this.ShowInTaskbar = false;
166 this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
167 this.groupBox1.ResumeLayout(false);
168 this.groupBox2.ResumeLayout(false);
169 this.groupBox3.ResumeLayout(false);
170 this.ResumeLayout(false);
173 #endregion
175 /// <summary>The configuration options for this dialog.</summary>
176 private ConfigurationOptions _options = new ConfigurationOptions();
178 /// <summary>Gets the configuration options.</summary>
179 public ConfigurationOptions ConfiguredOptions { get { return _options; } }
181 /// <summary>Sets up the form based on the current configuration options.</summary>
182 protected override void OnVisibleChanged(EventArgs e)
184 if (Visible)
186 chkHighlightEasyCell.Checked = _options.SuggestEasyCells;
187 chkShowIncorrectCells.Checked = _options.ShowIncorrectCells;
188 chkCreateWithSymmetry.Checked = _options.CreatePuzzlesWithSymmetry;
189 chkPromptOnDelete.Checked = _options.PromptOnPuzzleDelete;
190 chkParallelPuzzleGeneration.Checked = _options.ParallelPuzzleGeneration;
191 chkSpeculativeGeneration.Checked = _options.SpeculativePuzzleGeneration;
192 ConfiguredEnabledCheckboxes();
194 btnOK.Select();
196 base.OnVisibleChanged (e);
199 /// <summary>Sets up the configuration options based on the status of the form.</summary>
200 private void btnOK_Click(object sender, System.EventArgs e)
202 _options.SuggestEasyCells = chkHighlightEasyCell.Checked;
203 _options.ShowIncorrectCells = chkShowIncorrectCells.Checked;
204 _options.CreatePuzzlesWithSymmetry = chkCreateWithSymmetry.Checked;
205 _options.PromptOnPuzzleDelete = chkPromptOnDelete.Checked;
206 _options.ParallelPuzzleGeneration = chkParallelPuzzleGeneration.Checked;
207 _options.SpeculativePuzzleGeneration = chkSpeculativeGeneration.Checked;
210 /// <summary>Enables or disables the highlight easy cells option based on the show incorrect values option.</summary>
211 private void chkShowIncorrectCells_CheckedChanged(object sender, System.EventArgs e)
213 ConfiguredEnabledCheckboxes();
216 /// <summary>Configures chkHighlightEasyCell based on whether chkShowIncorrectCells is checked.</summary>
217 private void ConfiguredEnabledCheckboxes()
219 if (chkShowIncorrectCells.Checked)
221 chkHighlightEasyCell.Enabled = true;
223 else
225 chkHighlightEasyCell.Enabled = false;
226 chkHighlightEasyCell.Checked = false;